const logout = document.querySelector('.logout');       //退出按钮
const oneAList = document.querySelectorAll('.nav>li>a');   //一级标题数组  控制面板
const twoAList = document.querySelectorAll('.nav ul a');   //二级标题数组
const init = document.querySelector('.init');               //初始化页面
const search = document.querySelector('.search');       //搜索

logout.addEventListener('click', function (e) {         //退出点击事件

    if (confirm('您确定要退出吗？')) {
        // 退出则清空token
        localStorage.removeItem('token');
        // 返回登录页面
        location.href = "login.html";
    }
})
// 一级标题
oneAList.forEach(one => {
    one.addEventListener('click', e => {
        // one.nextElementSibling.classList.toggle('show');
        $(one).next().fadeToggle(400);
    })
});
// 二级标题
twoAList.forEach(two => {
    two.addEventListener('click', e => {
        // 移除所有remove类
        document.querySelector('.nav ul a.active').classList.remove('active');
        // 给点击的a标签添加active类
        two.classList.add('active')
    })
})
// 初始化获取分数方法
async function getScore() {
    const res = await axios({
        url: '/init/data',
        // headers: {
        //     Authorization: localStorage.getItem('token')
        // }
    })
}

init.addEventListener('click', function (e) {
    getScore()
})